home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Softdisk Supreme
/
Softdisk Supreme.iso
/
pc
/
DSK Files
/
0-49
/
SD005b.dsk
/
JUMBLER.bas
< prev
next >
Wrap
BASIC Source File
|
2003-06-12
|
6KB
|
151 lines
20 DIM J$(40)
30 TEXT
50 HOME : VTAB 10: HTAB 12: PRINT "JUMBLER / UNJUMBLER": PRINT : HTAB 7: PRINT "BY DANIEL TOBIAS JAN. 1982"
60 PRINT : HTAB 7: INPUT "(J)UMBLE OR (U)NJUMBLE? ";I$
70 IF LEFT$(I$,1) = "J" THEN 10000
100 REM START
105 T = 1
110 HOME : PRINT
115 PRINT "ENTER JUMBLE YOU WANT TO SOLVE:": GOSUB 500:J$ = I$
120 IF J$ = "" THEN 115
125 JU$ = J$
130 REM
135 K$ = "": FOR A = 1 TO LEN(J$)
140 IF MID$ (J$,A,1) < >" " THEN K$ = K$ +"-"
145 NEXT A: HOME
150 HTAB 1: VTAB 6: PRINT "JUMBLED STRING:": HTAB 1: VTAB 10: PRINT "UNJUMBLED STRING:"
152 HTAB 1: VTAB 16: PRINT "==========================": PRINT " CTRL-I: INSERT SPACE": PRINT " CTRL-D: DELETE CHARACTER"
153 PRINT " ARROWS: MOVE CURSOR"
154 PRINT " RETURN: EXIT PROGRAM"
155 REM
160 GOSUB 1000
165 F = 0: FOR B = 1 TO LEN(J$)
170 IF I$ = MID$ (J$,B,1) AND F = 0 THEN GOSUB 200
175 I = T
180 NEXT B: IF F = 0 THEN VTAB 14: HTAB 1: PRINT "THERE IS NO '"I$"'.": CALL -868:I$ = "-": GOSUB 300: GOTO 155
185 T = T +1
190 GOSUB 300: GOTO 155
200 REM INSERT *
210 F = 1
220 IF B = 1 THEN J$ = "*" + MID$ (J$,2)
230 IF B = LEN(J$) THEN J$ = LEFT$(J$, LEN(J$) -1) +"*"
240 IF B >1 AND B < LEN(J$) THEN J$ = LEFT$(J$,B -1) +"*" + MID$ (J$,B +1)
250 RETURN
300 REM UPDATE SOLVING $
310 IF I = 1 THEN K$ = I$ + MID$ (K$,2)
320 IF I > = LEN(K$) THEN K$ = LEFT$(K$, LEN(K$) -1) +I$
330 IF I >1 AND I < LEN(K$) THEN K$ = LEFT$(K$,I -1) +I$ + MID$ (K$,I +1)
340 RETURN
500 REM INPUT
505 I$ = ""
510 GET A$
520 IF A$ = CHR$(8) THEN GOSUB 555: GOTO 510
522 IF LEN(I$) >38 AND A$ < > CHR$(13) THEN PRINT "<CTRL-G>";: GOTO 510
523 IF A$ = CHR$(13) THEN PRINT : RETURN
524 IF A$ = "*" OR A$ = "-" OR A$ <" " THEN PRINT "<CTRL-G>";: GOTO 510
525 PRINT A$;
545 I$ = I$ +A$
550 GOTO 510
555 REM <--
560 IF I$ = "" THEN RETURN
565 IF LEN(I$) = 1 THEN I$ = ""
570 IF LEN(I$) >1 THEN I$ = LEFT$(I$, LEN(I$) -1)
575 PRINT A$;: CALL -868: RETURN
700 REM GET RID OF THE RIGHTMOST -
705 D = 0
710 IF RIGHT$(K$,1) = "-" THEN K$ = LEFT$(K$, LEN(K$) -1): RETURN
720 X = LEN(K$) -1
730 IF MID$ (K$,X,1) = "-" THEN K$ = LEFT$(K$,X -1) + MID$ (K$,X +1): RETURN
740 X = X -1
745 IF (X <T) AND D = 0 THEN T = T -1:D = 1
750 IF X >1 THEN 730
760 IF LEFT$(K$,1) = "-" THEN K$ = MID$ (K$,2): RETURN
765 IF D = 1 THEN T = T +1
770 VTAB 14: HTAB 1: PRINT "NO MORE LETTERS.": POP : GOTO 1000
1000 REM WAIT FOR INPUT
1005 HTAB 1: VTAB 8: PRINT J$;: CALL -868: HTAB 1: VTAB 12: PRINT K$;: CALL -868
1010 IF T <1 THEN T = 1
1020 IF T > LEN(K$) THEN T = LEN(K$)
1025 I = T
1030 VTAB 12: HTAB T
1040 GET I$
1042 IF I$ = "*" THEN 1040
1045 VTAB 14: HTAB 1: CALL -868
1050 IF I$ = CHR$(21) THEN T = T +1: GOTO 1000
1060 IF I$ = CHR$(8) THEN T = T -1: GOTO 1000
1070 IF I$ = CHR$(13) THEN 9000
1075 IF I$ = " " AND MID$ (K$,T,1) < >"-" AND MID$ (K$,T,1) < >" " THEN GOSUB 4000: GOSUB 300:K$ = K$ +"-"
1080 IF I$ = " " AND MID$ (K$,T,1) = "-" THEN GOSUB 300:K$ = K$ +"-"
1085 IF I$ = " " THEN T = T +1
1087 IF T > LEN(K$) THEN 1000
1090 IF I$ = "<CTRL-D>" AND MID$ (K$,T,1) = " " THEN GOSUB 3000: GOTO 1000
1092 IF I$ = "<CTRL-D>" AND MID$ (K$,T,1) = "-" THEN GOSUB 3000:K$ = K$ +"-": GOTO 1000
1095 IF I$ = "-" AND MID$ (K$,T,1) < >" " THEN GOSUB 4000
1097 IF I$ = "-" AND MID$ (K$,T,1) = " " THEN GOSUB 700:I = T: GOSUB 300
1098 IF I$ = "-" THEN T = T +1: GOTO 1000
1099 IF T > LEN(K$) THEN 1000
1100 I = ASC(I$): IF I >32 AND MID$ (K$,T,1) = "-" AND I$ < >"-" THEN RETURN
1110 IF I >32 AND MID$ (K$,T,1) = " " AND I$ < >"-" THEN GOSUB 700: RETURN
1120 IF I >32 AND ASC( MID$ (K$,T,1)) >32 AND I$ < >"-" THEN GOSUB 4000: RETURN
1130 IF I$ = "<CTRL-D>" AND ASC( MID$ (K$,T,1)) >32 THEN GOSUB 4000: GOSUB 3000:K$ = K$ +"-"
1140 IF I$ = "<CTRL-I>" THEN GOSUB 2000
1990 GOTO 1000
2000 REM ADD SPACE
2010 IF T = 1 THEN K$ = " " +K$
2020 IF T >1 THEN K$ = LEFT$(K$,T -1) +" " + MID$ (K$,T)
2030 RETURN
3000 REM REMOVE SPACE
3005 L = LEN(K$)
3010 IF T = 1 THEN K$ = MID$ (K$,2)
3020 IF T = L THEN K$ = LEFT$(K$, LEN(K$) -1)
3030 IF T >1 AND T <L THEN K$ = LEFT$(K$,T -1) + MID$ (K$,T +1)
3040 RETURN
4000 REM ELIMINATE
4005 D = 0
4010 O$ = MID$ (K$,T,1)
4020 FOR A = 1 TO LEN(JU$)
4030 IF MID$ (JU$,A,1) = O$ AND MID$ (J$,A,1) = "*" AND D = 0 THEN GOSUB 4500:D = 1
4040 NEXT A
4050 I = T: GOSUB 300
4060 RETURN
4500 REM
4510 IF A = 1 THEN J$ = LEFT$(JU$,1) + MID$ (J$,2)
4520 IF A = LEN(J$) THEN J$ = LEFT$(J$,A -1) + MID$ (JU$,A,1)
4530 IF A >1 AND A < LEN(J$) THEN J$ = LEFT$(J$,A -1) + MID$ (JU$,A,1) + MID$ (J$,A +1)
4540 RETURN
9000 REM END
9010 TEXT : HOME
9020 PRINT : PRINT "JUMBLE:": PRINT JU$: PRINT : PRINT "YOUR SOLUTION:": PRINT K$: PRINT
9025 J$ = JU$:T = 1
9030 INPUT "DO YOU WANT TO DO THE SAME JUMBLE OVER AGAIN? (Y/N) :";I$
9035 PRINT
9040 IF LEFT$(I$,1) = "Y" THEN 130
9050 INPUT "DO YOU WANT TO RUN THE PROGRAM AGAIN? (Y/N) :";I$: PRINT
9060 IF LEFT$(I$,1) = "Y" THEN RUN
9070 PRINT "SO LONG."
9080 END
10000 REM JUMBLE
10010 HOME : PRINT
10020 PRINT "ENTER LINE YOU WANT JUMBLED."
10030 GOSUB 500:J$ = I$
10040 IF J$ = "" THEN 10030
10050 K$ = LEFT$(" ", LEN(J$))
10055 N = LEN(J$)
10057 FOR J = 1 TO LEN(J$):J$(J) = "": NEXT J
10060 FOR J = 1 TO LEN(J$)
10070 R = INT(N * RND(1)) +1
10080 A = 1
10090 C = 0
10100 IF J$(A) = "" THEN C = C +1
10110 IF C = R THEN 10200
10120 A = A +1: GOTO 10100
10200 J$(A) = MID$ (J$,J,1)
10230 N = N -1: NEXT J
10232 K$ = ""
10235 FOR A = 1 TO LEN(J$):K$ = K$ +J$(A): NEXT A
10240 PRINT : PRINT "YOUR MESSAGE JUMBLED:"
10250 J$ = K$: PRINT J$
10255 JU$ = J$
10260 PRINT : INPUT "RUN UNJUMBLER WITH THIS JUMBLE (Y/N) :";I$: PRINT : IF LEFT$(I$,1) = "Y" THEN 130
10270 INPUT "RUN THE PROGRAM AGAIN? (Y/N) :";I$: PRINT : IF LEFT$(I$,1) = "Y" THEN RUN
10280 PRINT "SO LONG.": END